<?php

namespace App\Http\Controllers\Wechat;

use App\Http\Controllers\Controller;
use App\Models\Admin;
use Illuminate\Http\Request;

class SendTemplateController extends CommonController
{
    public function sendTemplate($openid,$name){
        $api = $this->wechatApp->getClient();
         $api->postJson('/cgi-bin/message/template/send',[
            'touser' => $openid,
            'template_id' => 'IzQIS7RgVTuhIZ8Mc6u9tb9UjiFJuaNvVE3nRTjTras',
            'data' => [
                'keyword1' => [
                    'value'=>$name,
                ],
                'keyword2' => [
                    'value'=>date('Y-m-d'),
                ],
                'remark'=>[
                    'value'=>'您的简历已通过审核'
                ],
            ],
        ]);
    }
    public function sendFailTemplate($openid,$reason){
        $api = $this->wechatApp->getClient();
         $api->postJson('/cgi-bin/message/template/send',[
            'touser' => $openid,
            'template_id' => '9kzhHEYhJQT_V4gPVWUsMooQioGo9p3UCDM4a2ifKFc',
            'url'=>'http://web.zjhzgroup.com/#/web/student/index',
            'data' => [
                'first'=>[
                    'value'=>'您的简历被拒绝，请修改后提交'
                ],
                'keyword1'=>[
                    'value'=>date('Y-m-d')
                ],
                'keyword2'=>[
                    'value'=>'审核不通过'
                ],
                'keyword3'=>[
                    'value'=>$reason
                ],
            ],
        ]);

    }

    //微信模板消息
    public function sendWaittingCheckTemplate($openid,$username,$content){
        $api = $this->wechatApp->getClient();
        $api->postJson('/cgi-bin/message/template/send',[
            'touser' => $openid,
            'template_id' => 'e01-wx4B9Kl74zoJuizQOZS_WWDmPGmwPFzA6X5zp6E',
            'page'=>'http://web.zjhzgroup.com/#/web/student/index',
            'data' => [
                'first'=>[
                    'value'=>'等待审核通知'
                ],
                'keyword1'=>[
                    'value'=>$username,//申请人
                ],
                'keyword2'=>[
                    'value'=>$content,//申请信息
                ],
                'remark'=>[
                    'value'=>'资料已经提交，1个工作日内审核结果'
                ],
            ],
        ]);
    }
    //企业审核成功
    public function sendCheckSuccessTemplate($openid){
        $api = $this->wechatApp->getClient();
        $info = $api->postJson('/cgi-bin/message/template/send',[
            'touser' => $openid,
            'template_id' => 'qGOnY7H1DxwM03CEtI1gbV080hcYNhpoZGwSYomTAmY',
            'url'=>'http://web.zjhzgroup.com/#/web/company/index',
            'data' => [
                'first'=>[
                    'value'=>'审核成功通知'
                ],
                'keyword1'=>[
                    'value'=>'审核成功',//操作人
                ],
                'keyword2'=>[
                    'value'=>date('Y-m-d H:i:s'),
                ],
                'remark'=>[
                    'value'=>'恭喜,您已经审核通过'
                ],
            ],
        ]);
    }
    //邀请函
    public function sendPostCardTemplate($openid,$username,$urls){
        $api = $this->wechatApp->getClient();
        $url = urlencode($urls);
        $api->postJson('/cgi-bin/message/template/send',[
            'touser' => $openid,
            'template_id' => 'eOfkzN55cew7svNVT02b23-dfICE_KeAxFner91ucEo',
            'url'=>'http://web.zjhzgroup.com/offer.html?img='.$url,
            'data' => [
                'first'=>[
                    'value'=>'录用成功通知'
                ],
                'keyword1'=>[
                    'value'=>'浙江获者电子商务有限公司',
                ],
                'remark'=>[
                    'value'=>'点击查看邀请函'
                ],
            ],
        ]);
    }
}
